package cn.wang.page.controller;

import cn.wang.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@Controller
public class PageController {
    @Autowired
    PageService pageService;

    @RequestMapping("/item/{id}.html")
    public String toHello(@PathVariable("id") Long spuId, Model model){
        // 向model中添加数据
        // 查询spu和spuDetail以及sku的信息
        Map<String,Object> map = pageService.queryPage(spuId);
        model.addAllAttributes(map);
        // 查询specGroup和spec的信息
        return "item";
    }
}
